#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5,M = 1e5,L = 1e6;

int T;
int n,m,l,maxv,maxd;
float V;
int p[M + 5];
bool ton[L + 5];


struct node{
	int d;
	float v,a;
}car[N + 5];

int read(){
	int x = 0,f = 1;
	char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0',c = getchar();
	return x * f;
}

void A(){
	int ans = 0;
	int cnt = 1;
	for(int i = 1;i <= n;i++){
		if(car[i].v > V && maxd >= car[i].d)
			ans++;
	}
	if(ans == 0)
		cnt = 0;
	printf("%lld %lld\n",ans,m - cnt);
	return ;
}

void B(){//ai > 0
	int ans = 0;
	int cnt = 1;
	for(int i = 1;i <= n;i++){
		if(maxd < car[i].d)
			continue; 
		float v2 = sqrt(2.0 * car[i].a * (maxd - car[i].d) + car[i].v * car[i].v);
		if(v2 > V)
			ans++;
	}
	if(ans == 0)
		cnt = 0;
	printf("%lld %lld\n",ans,m - cnt);
	return ;
}

bool cmp(node x,node y){
	return x.d < y.d;
}

void C(){//ai < 0
	int ans = 0;
	int poi = m;
	int pre = m + 1;
	int cnt = 0;
	sort(car + 1,car + n + 1,cmp);
	sort(p + 1,p + m + 1);
	for(int i = n;i >= 1;i--){
		if(maxd < car[i].d)
			continue;
		float gx = 2.0 * car[i].a * (p[pre] - car[i].d) + car[i].v * car[i].v;
		if(gx > V * V && pre != m + 1){
			ans++;
			continue;
		}
		else {
			bool f = false;
			poi = pre - 1;
			while(p[poi] >= car[i].d){
				gx = 2.0 * car[i].a * (p[poi] - car[i].d) + car[i].v * car[i].v;
				if(gx > V * V){
					f = true;
				}
				poi--;
			}
			if(f){
				pre = poi + 1;
				ans++;
				cnt++;
			}
		}
	}
	if(ans == 0)
		cnt = 0;
	printf("%lld %lld\n",ans,m - cnt);
}

signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T = read();
	while(T--){
		memset(ton,0,sizeof(ton));
		int c1 = 1,c2 = 1,c3 = 1;
		maxv = 0,maxd = 0;
		n = read(),m = read(),l = read(),V = read();
		for(int i = 1;i <= n;i++){
			car[i].d = read(),car[i].v = read(),car[i].a = read();
			if(car[i].a < 0)
				c1 = 0,c2 = 0;
			if(car[i].a == 0)
				c2 = 0,c3 = 0;
			if(car[i].a > 0)
				c1 = 0,c3 = 0;
			maxv = max(maxv,(int)car[i].v);
		}
		for(int i = 1;i <= m;i++){
			p[i] = read(),ton[p[i]] = true;
			maxd = max(maxd,p[i]);
		}
			
		if(c1 == 1){
			A();
			continue;
		}
		if(c2 == 1){
			B();
			continue;
		}
		if(c3 == 1){
			C();
			continue;
		}
	}
	return 0;
}
